import { baseApiUrl, path } from "../../utils/config";
import { courseInfo } from '../../utils/api';
const app = getApp();
Page({
  data: {
    baseImageUrl: baseApiUrl,
    id: null,
    poster: "",
    src: "",

    name: "",
    price: "",
    duration: "",
    unique: [],
    synopsis: "",
    content: "",

    video: null
  },
  async onLoad(options) {
    let id = options.id;
    let { course } = await courseInfo({ id });
    let { name, price, duration, learn_number, unique, synopsis, content } = course;
    let poster = course.thumbnail;
    let src = course.video;
    this.setData({ id, poster, src, name, price, duration, learn_number, unique, synopsis, content });
  },
  async submit() {
    const video = wx.createVideoContext("video")
    video.play()
  },
  onShareAppMessage() {
    let poster = app.globalData.poster;
    return {
      path,
      imageUrl: poster
    }
  },
  onShareTimeline() { }
})